#include "bus.h"


bus::bus(int cdmin, int cdmax, int idmmin, int idmmax):
	continuityDelayMin(cdmin),
	continuityDelayMax(cdmax),
	intervalDelayMin(idmmin),
	intervalDelayMax(idmmax)
{

}

void bus::SetReceiveMode(BUS_ReceiveModeType mode)
{
	if (BUS_Read == mode)
	{
		receivemode = mode;
	}
}

void bus::SetReceiveMode(BUS_ReceiveModeType mode, void(*callback)(unsigned char* data, unsigned short size))
{
	if (BUS_CallBack == mode)
	{
		receivemode = mode;
		ReceiveDataCallback = callback;
	}
}

void bus::SendStreamA2B(const unsigned char* data, unsigned short size)
{
	for (int i = 0; i < size; ++i)
	{
		channelA2B.push(data[i]);
		SendByteRecA2B.push_back(data[i]);
	}
}


void bus::SendStreamB2A(const unsigned char* data, unsigned short size)
{
	for (int i = 0; i < size; ++i)
	{
		channelB2A.push(data[i]);
		SendByteRecB2A.push_back(data[i]);
	}
}

void* bus::ChannelFuncRounter(void* param)
{
	((bus*)param)->ChannelFuncA2B();
	return nullptr;
}

void bus::ChannelFuncA2B(void)
{

}

void bus::ChannelFuncB2A(void)
{

}
